package 寒假刷题;

import java.util.ArrayList;
import java.util.List;

public class 适合打劫银行的日子 {
    public List<Integer> goodDaysToRobBank(int[] security, int time) {
        int n = security.length;
        int[] left = new int[n];
        int[] right = new int[n];
        for (int i = 1; i < n; i++) {
            if (security[i]<=security[i-1])
                left[i] = left[i-1]+1;
            if (security[n-i-1]<=security[n-i])
                right[n-i-1] = right[n-i]+1;
        }
        List<Integer> list = new ArrayList<>();
        for (int i = time; i < n-time; i++) {
               if (left[i]>=time && right[i]>=time)
                   list.add(i);
        }
        return list;
    }
}
